package com.librelato.persistencia;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.librelato.bean.HistoricoBean;
import com.librelato.bean.UsuarioBean;
import com.librelato.persistencia.config.SQLConfiguracao;
import com.librelato.persistencia.enums.EnumCondicao;
import com.librelato.persistencia.interfaces.IHistoricoChamadoDao;

public class HistoricoChamadoDao<P extends HistoricoBean> extends
		DaoGenerico<P> implements IHistoricoChamadoDao<P> {

	@Override
	public String procuraPorParam(String tabela, String campo, String valor,
			EnumCondicao condicao) {
		return null;
	}

	@Override
	public P salvar(P p) throws Exception {
		return null;
	}

	@Override
	public void excluir(P p) throws Exception {
		
	}

	@Override
	public void editar(P p) throws Exception {
	}

	@Override
	public void preSalvar(P p) {
	}
	
	
	@Override
	public List<HistoricoBean> buscaHistoricos(Map<String, String> param) throws Exception {
		HistoricoBean historico = null;
		List<HistoricoBean> historicos = new ArrayList<HistoricoBean>();
		conn = GerenciadorConexao.getConexao();
		query = SQLConfiguracao.getInstance().getValor("localiza_historico_chamado");
		ps = conn.prepareStatement(query);
		ps.setLong(1, Long.parseLong(param.get("IDCHAMADO")));
		rs = ps.executeQuery();
		while(rs.next()){
			historico = new HistoricoBean();
			historico.setCodigo(rs.getLong("IDHISTORICO"));
			historico.setDataEmissao(rs.getTimestamp("DATA"));
			historico.setDescricao(rs.getString("DESCRICAO"));
			historico.setProgresso(rs.getDouble("PROGRESSO"));
			historico.setUsuario(new UsuarioBean(rs.getLong("IDUSUARIO")+"","",null));
			historicos.add(historico);
		}
		
		return historicos;
	}
	
	
	

}
